<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Jedrzej\Pimpable\PimpableTrait;
use Illuminate\Database\Eloquent\SoftDeletes;

class ProductAttrResult extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;

    /**
     * 表中的类型状态
     */
    //参与的活动类型
    public $typeTypeEnum = [
        'noActivity' => '普通商品',
        'seckill' => '秒杀',
        'bargain' => '砍价',
        'combination' => '拼团'
    ];

    /**
     * 可搜索字段 无
     */

    /**
     * 可批量赋值字段
     */
    public $fillable = [
        'result'
    ];

    /**
     * 强制转换
     */
    public $casts = [
        'result'=>'array'
    ];


    /**
     * 可排序字段
     */
    public $sortable = ['created_at', 'id'];

    /**
     * 默认排序字段
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 关联的商品
     */
    function product(){
        return $this->belongsTo(Product::class,'product_id','id');
    }
}
